package com.koron.dynamic.config;

import com.koron.dynamic.controller.KrDataSourceController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @ClassName CoreWeLinkInitListener
 * @description ApplicationRunner
 * @Author zhouj
 * @Date 2021/7/19 17:34
 */
@Slf4j
@Order(1)
@Component
public class CoreDynamicInitListener implements ApplicationRunner {

    @Autowired
    KrDataSourceController controller;

    @Override
    public void run(ApplicationArguments args) {

        log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~开始启动多数据源注册~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

        new Thread(() -> {
            controller.registryMultDb(null);
            log.info("初始化数据库注册完成");
        }).start();
    }

}
